﻿using UnityEngine;
using System.Collections;
using UnityEngine.Networking;

public class EnemySpawner : NetworkBehaviour
{
    public GameObject enemyPrefab;
    public int numberOfEnemies;

    public override void OnStartServer()
    {
        base.OnStartServer();
        for(int i = 0; i < numberOfEnemies; i++)
        {
            CreateEnemy();
        }
    }

    public void CreateEnemy()
    {
        Vector3 position = new Vector3(Random.Range(-6, 6), 0, Random.Range(-6, 6));
        Quaternion rotation = Quaternion.Euler(0, Random.Range(0, 360), 0);
        GameObject enemy = Instantiate(enemyPrefab, position, rotation) as GameObject;

        NetworkServer.Spawn(enemy);
    }
}
